<?php get_instance()->view('common/header');?>
<style>
	.box.box-info {
		border-top-color: #e6e6e6;
	}
	.box-header.with-border {
		border-bottom: 1px solid #f4f4f4;
	}
	.box-body {
		border-top-left-radius: 0;
		border-top-right-radius: 0;
		border-bottom-right-radius: 3px;
		border-bottom-left-radius: 3px;
		padding: 10px;
	}
	.box-header {
		color: #444;
		display: block;
		padding: 10px;
		position: relative;
	}
	.box.box-primary {
		border-top-color: #3c8dbc;
	}
	.box {
		position: relative;
		border-radius: 3px;
		background: #ffffff;
		border-top: 3px solid #d2d6de;
		margin-bottom: 20px;
		width: 100%;
		box-shadow: 0 1px 1px rgba(0,0,0,0.1);
	}
	#list-table>thead>tr:nth-child(2)>th{
		font-size: 12px;
		font-weight: 700;
		color:#666;
	}
	#list-table>tbody>tr>td{
		color: #808080;
	}
	tbody>tr>td:nth-child(1), thead>tr>th:nth-child(1) {
		width: auto !important;
		white-space: pre-line !important;
	}
	tbody>tr>td:nth-child(2), thead>tr>th:nth-child(2) {
		width: auto !important;
		white-space: pre-line !important;
	}
	td,th{
		vertical-align: middle !important;
	}
</style>
<div class="page-container wrapper">
	<!-- BEGIN SIDEBAR -->
    <?php get_instance()->view('common/sidebar');?>
	<!-- END SIDEBAR -->
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content" style="min-height:1200px !important">
			<!-- BEGIN PAGE HEADER-->
			<div class="col-xs-12">
				<div class="">
					<div class="row">
						<div class="col-md-12">
							<div class="box box-info">
								<div class="box-header with-border">
									<div class="row">
										<div class="col-md-12">
                                            <div class="col-xs-5">
                                                <div class="input-group margin">
                                                    <div class="input-group-addon">
                                                        选择时间  <i class="fa fa-calendar"></i>
                                                    </div>
                                                    <input type="text" class="form-control form-filter pull-right" name="timegap" value="<?php echo $startTime .' - '. $endTime?>" id="start_time">
                                                </div>
                                                <div id="statistics" style="display:none"></div>
                                            </div>
                                            <div class="col-xs-2">
                                                <div class="input-group margin">
                                                    <div class="input-group-addon">选择红包类型</div>
                                                    <select name="type" class=" form-control form-filter input-inline input-small input-sm">
                                                        <option value="0"><?php echo '所有';?></option>
                                                        <?php foreach ($bonus_type as $k =>$v):?>
                                                            <option value="<?php echo $k?>" ><?php echo $v?></option>
                                                        <?php endforeach;?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-xs-2 col-xs-offset-3"><input class="btn btn-block btn-info margin add-btn" type="submit" value="确定"></div>
										</div>
									</div>
								</div>
								<div class="box-body">
									<div class="row">
										<div class="col-sm-6 col-xs-6">
											备注：此表显示的是一定时间内红包信息
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<style>
						#list-table td,th{text-align: center;}
					</style>
					<div class="row">
						<div class="col-sm-12">
							<div class="panel panel-default">
								<div class="panel-heading">
									<h3 class="panel-title" style="height: 32px;line-height: 32px;"><i class="fa fa-list"></i> 红包概览
                                        <?php if(adminAuthority('bonus-export', 'statistics')):?>
                                            <a href="javascript:;"  class="btn btn-info margin fr export" style="color: #fff"> 导出</a>
                                        <?php endif;?>
                                    </h3>
								</div>
								<div class="panel-body">
									<table id="list-table" class="table table-bordered table-striped" >
										<thead>
                                            <tr>
                                                <th>红包名称</th>
                                                <th>类型</th>
                                                <th>红包金额</th>
                                                <th>发放数量</th>
                                                <th>使用数量</th>
                                                <th>未使用数量</th>
                                                <th>失效数量</th>
                                                <th>使用总金额</th>
                                                <th>红包总金额</th>
                                                <th>时间</th>
                                            </tr>
                                        </thead>
                                        <tbody></tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- END CONTENT -->
</div>
<script type="text/javascript">
	$(document).ready(function() {
        datatable_init({
            "sDom": "<'row'<'col-md-5 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>",
            src: $("#list-table"),
            sAjaxSource: "<?php echo getUrl('statistics/bonus/getList');?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [0,1]
            }]
        });

		$('#start_time').daterangepicker({
			format:"YYYY-MM-DD",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2016-01-01',
			maxDate:'2030-01-01',
			startDate:'2016-01-01',
			showWeekNumbers: true,
			timePicker: false,
			timePickerIncrement: 1,
			timePicker12Hour: true,
			ranges: {
				'今天': [moment(), moment()],
				'昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
				'最近7天': [moment().subtract('days', 6), moment()],
				'最近30天': [moment().subtract('days', 29), moment()],
				'上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
			},
			opens: 'right',
			buttonClasses: ['btn btn-default'],
			applyClass: 'btn-small btn-primary',
			cancelClass: 'btn-small',
			locale : {
				applyLabel : '确定',
				cancelLabel : '取消',
				fromLabel : '起始时间',
				toLabel : '结束时间',
				customRangeLabel : '自定义',
				daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
				monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
				firstDay : 1
			}
		});

		$(".add-btn").click(function () {
            $("#list-table").dataTable().fnDraw(true)
        });

		$(".export").click(function () {
            var vl = $("[name='timegap']").val();
            var type = $("[name='type']").val();
            window.location.href = '<?php echo getUrl("statistics/bonus/export")?>?timegap='+vl+'&type='+type;
        });
	});
</script>
</body>
</html>